using System.Collections;
using System.Collections.Generic;
using UnityEngine;

public class Player_WallSlideState : PlayerStateBase
{
    public Player_WallSlideState(Player player, StateMachine stateMachine, string animName) : base(player, stateMachine, animName)
    {

    }

    public override void Update()
    {
        base.Update();
        if (input.Player.Jump.WasPressedThisFrame() && player.moveInput.x!=player.facingDir)
        {
            stateMachine.ChangeState(player.wallJumpState);
            return;
        }

        HandleWallSlideSpeed();

        if (!player.IsWall)
            stateMachine.ChangeState(player.jumpFallState);

        if (player.IsGround)
            stateMachine.ChangeState(player.idleState);
    }
    private void HandleWallSlideSpeed()
    {
        if (player.moveInput.y < 0)
            player.SetVelocity(player.moveInput.x, rb.velocity.y);
        else
            player.SetVelocity(player.moveInput.x, rb.velocity.y * player.wallSlideSlowMutiplier);
    }
}
